/*
 * @Descripttion: toolkit的createReducer模块
 * @Author: lukasavage
 * @Date: 2021-12-07 21:10:44
 * @LastEditors: lukasavage
 * @LastEditTime: 2021-12-07 21:26:31
 */

function createReducer(initialState, actionMap = {}) {
    return function (state = initialState, action) {
        let reducer = actionMap[action.type];
        // 如果在createReducer中匹配到了，则返回调用reducer后的新的状态
        if (reducer) return reducer(state, action);
        // 没有返回默认值
        return state;
    }
}
export default createReducer;